<template>
	<view :style="{ '--color': vuex_config.themeColor1, '--price': vuex_config.price }">
		<view v-if="!parameter.layout || parameter.layout == 1" class="vip-list">
			<view class="vip-item" @click="open(item)" v-for="(item, index) in dataList" :key="index">
				<image class="item-img" :src="(item.img || '').split(',')[0]" mode="aspectFill"></image>
				<view class="item-right">
					<view class="title u-line-2">{{ item.name }}</view>
					<view class="item_bot">
						<view class="price">
							<view class="present-price">
								<text class="u-font-28 icon">￥</text>
								<text class="num u-font-42">{{ item.amount || 0 }}</text>
							</view>
							<view class="Marking-price" v-if="item.cost_price > item.amount">￥{{ item.cost_price }}
							</view>
						</view>
						<view class="box-btn">
							<view class="btn">立即购买</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else-if="parameter.layout == 2" class="memberList">
			<view v-for="(item, index) in dataList" :key="index" class="memberList-box" @click="open(item)">
				<view class="thimg">
					<image mode="aspectFill" class="img" :src="item.img ? item.img.split(',')[0] : ''" />
				</view>
				<view class="details">
					<view class="details_title u-line-1">{{ item.name }}</view>
					<view class="salesVolume" v-if="vuex_config.sales_volume == 1 && item.order_num > 0">
						已售{{ item.order_num }}+</view>
					<view class="price-box">
						<text class="price-icon">￥</text>
						<text class="price-num">{{ item.amount || 0 }}</text>
						<text v-if="item.cost_price > item.amount" class="price-link">￥{{ item.cost_price }}</text>
					</view>
				</view>
			</view>
		</view>
		<view v-else-if="parameter.layout == 3" class="sign_row">
			<view v-for="(item, index) in dataList" :key="index" class="sign_item" @click="open(item)">
				<view class="img_view">
					<image class="img" :src="item.img ? item.img.split(',')[0] : ''" mode="aspectFill" />
				</view>
				<view class="sign_cont">
					<view class="title">{{ item.name }}</view>
					<view class="price_box">
						<text class="price-icon">￥</text>
						<text class="price-num">{{ item.amount || 0 }}</text>
						<text v-if="item.cost_price > item.amount" class="price-link">
							￥{{ item.cost_price }}
						</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			parameter: {
				type: Object,
				default: () => {
					return {};
				}
			},
			dataList: {
				type: Array,
				default: []
			}
		},
		components: {},
		data() {
			return {};
		},

		mounted() {},

		methods: {
			open(item) {
				this.$toProd({
					...item,
					prodType: 11
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.vip-list {
		background-color: #fff;
		padding: 10rpx 30rpx 0;

		.vip-item {
			display: flex;
			padding-bottom: 20rpx;

			.item-img {
				border-radius: 10rpx;
				overflow: hidden;
				width: 230rpx;
				height: 230rpx;
				margin-right: 20rpx;
			}

			.item-right {
				flex: 1;
				overflow: hidden;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					line-height: 42rpx;
					height: 84rpx;
					padding-top: 10rpx;
					box-sizing: content-box;
					font-size: 30rpx;
				}

				.price {
					display: flex;
					align-items: center;

					.present-price {
						display: flex;
						align-items: center;
						color: var(--price);

						.icon {
							position: relative;
							top: 4rpx;
						}

						.num {
							font-weight: bold;
						}
					}

					.Marking-price {
						text-decoration: line-through;
						font-size: 24rpx;
						color: #999;
						margin-left: 10rpx;
						position: relative;
						top: 4rpx;
					}
				}

				.box-btn {
					width: 100%;
					display: flex;
					margin: 12rpx 0 8rpx;
					justify-content: flex-end;

					.btn {
						padding: 8rpx 26rpx;
						background: var(--color);
						color: #fff;
						text-align: center;
						border-radius: 30rpx;
						font-size: 26rpx;
					}
				}
			}
		}
	}

	.memberList {
		background-color: #fff;
		padding: 20rpx 26rpx 10rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		img {
			width: 100%;
			height: 100%;
			object-fit: cover;
		}

		.memberList-box {
			width: calc(50% - 12rpx);
			box-shadow: 0px 4rpx 10rpx 2rpx rgba(153, 152, 152, 0.15);
			border-radius: 8rpx;
			overflow: hidden;
			margin-bottom: 20rpx;
			display: flex;
			flex-direction: column;

			.thimg {
				width: 100%;
				padding-bottom: 74.6%;
				position: relative;

				.img {
					position: absolute;
					top: 0;
					left: 0;
				}
			}
		}

		.details {
			flex: 1;
			overflow: hidden;
			display: flex;
			flex-direction: column;
			padding: 16rpx;

			.details_title {
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}

			.salesVolume {
				font-size: 24rpx;
				color: #666;
				margin-top: 10rpx;
			}

			.price-box {
				margin-top: auto;
				padding-top: 12rpx;


				.price-icon {
					font-size: 24rpx;
					color: #ff1f00;
					font-weight: bold;
				}

				.price-num {
					font-size: 36rpx;
					font-weight: bold;
					color: #ff1f00;
					margin-right: 8rpx;
				}

				.price-link {
					text-decoration: line-through;
					font-size: 26rpx;
					color: #666;
					font-family: PingFang SC;
				}
			}
		}
	}

	.sign_row {
		padding: 10rpx 20rpx 0;

		.sign_item {
			border: 2rpx solid #fff;
			border-radius: 24rpx;
			overflow: hidden;
			margin-bottom: 18rpx;

			&:last-of-type {
				margin-bottom: 0;
			}

			.img_view {
				padding-bottom: 37.2%;
				width: 100%;
				position: relative;

				.img {
					position: absolute;
					top: 0;
					left: 0;
				}
			}

			.sign_cont {
				background-color: #fff;
				padding: 0 18rpx 16rpx;
			}

			.title {
				color: #000;
				padding-top: 14rpx;
			}

			.price_box {
				margin-top: 6rpx;

				.price-icon {
					font-size: 24rpx;
					color: #ff1f00;
					font-weight: bold;
				}

				.price-num {
					font-size: 36rpx;
					font-weight: bold;
					color: #ff1f00;
					margin-right: 8rpx;
				}

				.price-link {
					text-decoration: line-through;
					font-size: 26rpx;
					color: #999;
					font-family: PingFang SC;
				}
			}
		}
	}
</style>
